package com.iss.lxhproject.service;

import com.iss.lxhproject.dao.RoomfreeDao;
import com.iss.lxhproject.dao.RoomfreeDao;
import com.iss.lxhproject.entity.Room;
import org.apache.ibatis.annotations.Param;
import org.omg.PortableInterceptor.INACTIVE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoomfreeService {
    @Autowired
    private RoomfreeDao roomfreeDao;
    public Integer insertRoom(Room room){
            Integer count = roomfreeDao.insertRoom(room);
           return count;
    }
    public boolean deleteRoom(String[] room_id){
        Integer count = roomfreeDao.deletRoom(room_id);
        System.out.println(count);
        if (count>0){
            return true;
        }else
            return false;
    }
    public boolean updatetRoom(Room room){
        Integer count = roomfreeDao.updateRoom(room);
        if (count>0){
            return true;
        }else
            return false;
    }
    public boolean selectRoom(String room_id){
        Room room = roomfreeDao.selectRoom(room_id);
        if(room!=null){
            return true;
        }else
            return false;
    }
    public List<Room> selectAllRooms(Double priceFrom,Double priceTo){
        List<Room> list =roomfreeDao.selectAllRoom(priceFrom,priceTo);
        return list;
    }
    public Room selectRoomfreeById(String room_id){
        return roomfreeDao.selectRoomfreeById(room_id);

    }

    public Integer updateRoomState(@Param("room_state") String room_state, @Param("room_id") String room_id){
        return roomfreeDao.updateRoomState(room_state,room_id);
    }

    public String selectRoomState(@Param("room_id")String room_id){
        return roomfreeDao.selectRoomState(room_id);
    }

    public Integer updateRoomState1(String[] checkout_room){
        return roomfreeDao.updateRoomState1(checkout_room);
    }
}
